<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>取得图像大小</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="function.gd-info.html">« gd_info</a></li>
      <li style="float: right;"><a href="function.getimagesizefromstring.html">getimagesizefromstring »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="ref.image.html">GD 和图像处理 函数</a></li>
    <li>取得图像大小</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="function.getimagesize" class="refentry">
  <div class="refnamediv">
   <h1 class="refname">getimagesize</h1>
   <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">getimagesize</span> &mdash; <span class="dc-title">取得图像大小</span></p>

  </div>
  <div class="refsect1 description" id="refsect1-function.getimagesize-description">
   <h3 class="title">说明</h3>
   <div class="methodsynopsis dc-description">
    <span class="methodname"><strong>getimagesize</strong></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$filename</code></span>, <span class="methodparam"><span class="type">array</span> <code class="parameter reference">&$imageinfo</code><span class="initializer"> = ?</span></span>): <span class="type">array</span></div>

   <p class="para rdfs-comment">
    <span class="function"><strong>getimagesize()</strong></span> 函数将测定任何
    <abbr title="Graphic Interchange Format">GIF</abbr>，<abbr>JPG</abbr>，<abbr title="Portable Network Graphics">PNG</abbr>，<abbr title="Shockwave Flash">SWF</abbr>，<abbr>SWC</abbr>，<abbr title="Photoshop Document">PSD</abbr>，<abbr title="Tagged Image File Format">TIFF</abbr>，<abbr title="Bitmap">BMP</abbr>，<abbr title="Interchange File Format">IFF</abbr>，<abbr title="JPEG-2000">JP2</abbr>，<abbr>JPX</abbr>，<abbr title="Joint Bilevel Image Experts Group">JB2</abbr>，<abbr title="Japan Picture">JPC</abbr>，<abbr title="X Bitmap">XBM</abbr>
    或 <abbr title="Wireless Bitmap">WBMP</abbr> 图像文件的大小并返回图像的尺寸以及文件类型和一个可以用于普通
    <abbr title="Hyper Text Markup Language">HTML</abbr> 文件中 <code class="tag">IMG</code> 标记中的
    height/width 文本字符串。
   </p>
   <p class="para">
    如果不能访问 <code class="parameter">filename</code>
    指定的图像或者其不是有效的图像，<span class="function"><strong>getimagesize()</strong></span>
    将返回 <strong><code>false</code></strong> 并产生一条 <var class="varname">E_WARNING</var> 级的错误。
   </p>
   <blockquote class="note"><p><strong class="note">注意</strong>: 
    <p class="para">
     对 <abbr title="Japan Picture">JPC</abbr>，<abbr title="JPEG-2000">JP2</abbr>，<abbr>JPX</abbr>，<abbr title="Joint Bilevel Image Experts Group">JB2</abbr>，<abbr title="X Bitmap">XBM</abbr>
     和 <abbr title="Wireless Bitmap">WBMP</abbr> 的支持自 PHP 4.3.2
     起可用。对 <abbr>SWC</abbr> 的支持自 PHP 4.3.0 起可用。对
     <abbr title="Tagged Image File Format">TIFF</abbr> 的支持是 PHP 4.2.0 添加的。
    </p>
   </p></blockquote>
   <blockquote class="note"><p><strong class="note">注意</strong>: 
    <span class="simpara">
     JPEG 2000 支持是 PHP 4.3.2 添加的。注意 JPC 和 JP2
     可以有不同的色彩深度的成分。此情况下，“bits”的值是碰到的最高的位深度。此外，JP2
     文件可能包含有多个 JPEG 2000 代码流，此情况下，<span class="function"><strong>getimagesize()</strong></span>
     返回此文件顶层中碰到的第一个代码流的值。
    </span>
   </p></blockquote>
   <blockquote class="note"><p><strong class="note">注意</strong>: 
    <span class="simpara">
     本函数不需要 GD 图像库。
    </span>
   </p></blockquote>
   <p class="para">
    返回一个具有四个单元的数组。索引 0 包含图像宽度的像素值，索引 1
    包含图像高度的像素值。索引 2 是图像类型的标记：1 = GIF，2 = JPG，3 =
    PNG，4 = SWF，5 = PSD，6 = BMP，7 = TIFF(intel byte order)，8 =
    TIFF(motorola byte order)，9 = JPC，10 = JP2，11 = JPX，12 =
    JB2，13 = SWC，14 = IFF，15 = WBMP，16 = XBM。这些标记与 PHP 4.3.0
    新加的 IMAGETYPE 常量对应。索引 3 是文本字符串，内容为“height=&quot;yyy&quot;
    width=&quot;xxx&quot;”，可直接用于 IMG 标记。
    <div class="example" id="example-2612">
     <p><strong>示例 #1 getimagesize（文件）</strong></p>
     <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">list(</span><span style="color: #0000BB">$width</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$height</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$type</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$attr</span><span style="color: #007700">)&nbsp;=&nbsp;</span><span style="color: #0000BB">getimagesize</span><span style="color: #007700">(</span><span style="color: #DD0000">"img/flag.jpg"</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #DD0000">"&lt;img&nbsp;src=\"img/flag.jpg\"&nbsp;</span><span style="color: #0000BB">$attr</span><span style="color: #DD0000">&gt;"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
     </div>

    </div>
   </p>
   <p class="para">
    URL 支持是 PHP 4.0.5 添加的。
    <div class="example" id="example-2613">
     <p><strong>示例 #2 getimagesize（URL）</strong></p>
     <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$size&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">getimagesize</span><span style="color: #007700">(</span><span style="color: #DD0000">"http://www.example.com/gifs/logo.gif"</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;if&nbsp;the&nbsp;file&nbsp;name&nbsp;has&nbsp;space&nbsp;in&nbsp;it,&nbsp;encode&nbsp;it&nbsp;properly<br /></span><span style="color: #0000BB">$size&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">getimagesize</span><span style="color: #007700">(</span><span style="color: #DD0000">"http://www.example.com/gifs/lo%20go.gif"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
     </div>

    </div>
   </p>
   <p class="para">
    对于 <abbr>JPG</abbr> 图像，还会多返回两个索引：<code class="literal">channels</code>
    和 <code class="literal">bits</code>。<code class="literal">channels</code>
    对于 RGB 图像其值为 3，对于 CMYK 图像其值为 4。<code class="literal">bits</code>
    是每种颜色的位数。
   </p>
   <p class="para">
    自 PHP 4.3.0 起，<code class="literal">bits</code> 和
    <code class="literal">channels</code> 对于其它图像类型也存在。但是这些值可能会把人搞糊涂。例如，<abbr title="Graphic Interchange Format">GIF</abbr>
    总是对每个像素使用 3 个 channel，但是对于动画 <abbr title="Graphic Interchange Format">GIF</abbr>
    来说每个像素的位数无法通过全局颜色表计算出来。
   </p>
   <p class="para">
    某些格式可能不包含图像或者包含多个图像。此种情况下，<span class="function"><strong>getimagesize()</strong></span>
    可能不能用来准确测定图像的大小。此时 <span class="function"><strong>getimagesize()</strong></span>
    将返回零作为宽度和高度。
   </p>
   <p class="para">
    自 PHP 4.3.0 起，<span class="function"><strong>getimagesize()</strong></span> 还会返回额外的参数
    <code class="literal">mime</code>，符合该图像的 MIME 类型。此信息可以用来在
    HTTP Content-type 头信息中发送正确的信息：
    <div class="example" id="example-2614">
     <p><strong>示例 #3 getimagesize() 和 MIME 类型</strong></p>
     <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$size&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">getimagesize</span><span style="color: #007700">(</span><span style="color: #0000BB">$filename</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$fp</span><span style="color: #007700">=</span><span style="color: #0000BB">fopen</span><span style="color: #007700">(</span><span style="color: #0000BB">$filename</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"rb"</span><span style="color: #007700">);<br />if&nbsp;(</span><span style="color: #0000BB">$size&nbsp;</span><span style="color: #007700">&amp;&amp;&nbsp;</span><span style="color: #0000BB">$fp</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;</span><span style="color: #0000BB">header</span><span style="color: #007700">(</span><span style="color: #DD0000">"Content-type:&nbsp;</span><span style="color: #007700">{</span><span style="color: #0000BB">$size</span><span style="color: #007700">[</span><span style="color: #DD0000">'mime'</span><span style="color: #007700">]}</span><span style="color: #DD0000">"</span><span style="color: #007700">);<br />&nbsp;&nbsp;</span><span style="color: #0000BB">fpassthru</span><span style="color: #007700">(</span><span style="color: #0000BB">$fp</span><span style="color: #007700">);<br />&nbsp;&nbsp;exit;<br />}&nbsp;else&nbsp;{<br />&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;error<br /></span><span style="color: #007700">}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
     </div>

    </div>
   </p>
   <p class="para">
    可选的 <code class="parameter">imageinfo</code>
    参数允许从图像文件中提取一些扩展信息。目前，这将以一个关联数组返回不同的
    <abbr>JPG</abbr> APP 标识。某些程序用这些 APP
    标识来在图像中嵌入文本信息。一个非常常见的是 APP13 标识中嵌入的
    <abbr>IPTC</abbr> <a href="http://www.iptc.org/" class="link external">&raquo;&nbsp;http://www.iptc.org/</a>
    信息。可以用 <span class="function"><a href="function.iptcparse.html" class="function">iptcparse()</a></span> 函数来将二进制的
    APP13 标识解析为可读的信息。
   </p>
   <p class="para">
    <div class="example" id="example-2615">
     <p><strong>示例 #4 getimagesize() 返回 IPTC</strong></p>
     <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$size&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">getimagesize</span><span style="color: #007700">(</span><span style="color: #DD0000">"testimg.jpg"</span><span style="color: #007700">,&nbsp;&amp;</span><span style="color: #0000BB">$info</span><span style="color: #007700">);<br />if&nbsp;(isset(</span><span style="color: #0000BB">$info</span><span style="color: #007700">[</span><span style="color: #DD0000">"APP13"</span><span style="color: #007700">]))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$iptc&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">iptcparse</span><span style="color: #007700">(</span><span style="color: #0000BB">$info</span><span style="color: #007700">[</span><span style="color: #DD0000">"APP13"</span><span style="color: #007700">]);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$iptc</span><span style="color: #007700">);<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
     </div>

    </div>
   </p>
   <p class="para">
    参见 <span class="function"><a href="function.image-type-to-mime-type.html" class="function">image_type_to_mime_type()</a></span>，<span class="function"><a href="function.exif-imagetype.html" class="function">exif_imagetype()</a></span>，<span class="function"><a href="function.exif-read-data.html" class="function">exif_read_data()</a></span>
    和 <span class="function"><a href="function.exif-thumbnail.html" class="function">exif_thumbnail()</a></span>。
   </p>
  </div>

 
 <div class="refsect1 parameters" id="refsect1-function.getimagesize-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt>
<code class="parameter">filename</code></dt>

     <dd>

      <p class="para">
        This parameter specifies the file you wish to retrieve information
        about. It can reference a local file or (configuration permitting) a
        remote file using one of the supported streams. 
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">imageinfo</code></dt>

     <dd>

      <p class="para">
       This optional parameter allows you to extract some extended
       information from the image file. Currently, this will return the
       different <abbr>JPG</abbr> APP markers as an associative array.
       Some programs use these APP markers to embed text information in 
       images. A very common one is to embed 
       <a href="http://www.iptc.org/" class="link external">&raquo;&nbsp;IPTC</a> information in the APP13 marker.
       You can use the <span class="function"><a href="function.iptcparse.html" class="function">iptcparse()</a></span> function to parse the
       binary APP13 marker into something readable.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>

 
 <div class="refsect1 returnvalues" id="refsect1-function.getimagesize-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns an array with 7 elements.
  </p>
  <p class="para">
   Index 0 and 1 contains respectively the width and the height of the image.
  </p>
  <blockquote class="note"><p><strong class="note">注意</strong>: 
   <p class="para">
    Some formats may contain no image or may contain multiple images. In these
    cases, <span class="function"><strong>getimagesize()</strong></span> might not be able to properly
    determine the image size. <span class="function"><strong>getimagesize()</strong></span> will return
    zero for width and height in these cases.
   </p>
  </p></blockquote>
  <p class="para">
   Index 2 is one of the <code class="literal">IMAGETYPE_XXX</code> constants indicating 
   the type of the image.
  </p>
  <p class="para">
   Index 3 is a text string with the correct 
   <code class="literal">height=&quot;yyy&quot; width=&quot;xxx&quot;</code> string that can be used
   directly in an <abbr>IMG</abbr> tag.
  </p>
  <p class="para">
   <code class="literal">mime</code> is the correspondant MIME type of the image.
   This information can be used to deliver images with the correct HTTP 
   <code class="literal">Content-type</code> header:
   <div class="example" id="example-2616">
    <p><strong>示例 #5 <span class="function"><strong>getimagesize()</strong></span> and MIME types</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$size&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">getimagesize</span><span style="color: #007700">(</span><span style="color: #0000BB">$filename</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$fp&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">fopen</span><span style="color: #007700">(</span><span style="color: #0000BB">$filename</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"rb"</span><span style="color: #007700">);<br />if&nbsp;(</span><span style="color: #0000BB">$size&nbsp;</span><span style="color: #007700">&amp;&amp;&nbsp;</span><span style="color: #0000BB">$fp</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">header</span><span style="color: #007700">(</span><span style="color: #DD0000">"Content-type:&nbsp;</span><span style="color: #007700">{</span><span style="color: #0000BB">$size</span><span style="color: #007700">[</span><span style="color: #DD0000">'mime'</span><span style="color: #007700">]}</span><span style="color: #DD0000">"</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">fpassthru</span><span style="color: #007700">(</span><span style="color: #0000BB">$fp</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;exit;<br />}&nbsp;else&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;error<br /></span><span style="color: #007700">}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
  <p class="para">
   <code class="literal">channels</code> will be 3 for RGB pictures and 4 for CMYK
   pictures.
  </p>
  <p class="para">
   <code class="literal">bits</code> is the number of bits for each color.
  </p>
  <p class="para">
   For some image types, the presence of <code class="literal">channels</code> and
   <code class="literal">bits</code> values can be a bit
   confusing. As an example, <abbr title="Graphic Interchange Format">GIF</abbr> always uses 3 channels
   per pixel, but the number of bits per pixel cannot be calculated for an
   animated <abbr title="Graphic Interchange Format">GIF</abbr> with a global color table.
  </p>
  <p class="para">
   On failure, <strong><code>false</code></strong> is returned.
  </p>
 </div>

 
 <div class="refsect1 errors" id="refsect1-function.getimagesize-errors">
  <h3 class="title">错误／异常</h3>
  <p class="para">
   If accessing the <code class="parameter">filename</code> image is impossible, or
   if it isn&#039;t a valid picture, <span class="function"><strong>getimagesize()</strong></span> will
   generate an error of level <strong><code>E_WARNING</code></strong>. On read error,
   <span class="function"><strong>getimagesize()</strong></span> will generate an error of level
   <strong><code>E_NOTICE</code></strong>.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.getimagesize-changelog">
  <h3 class="title">更新日志</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>版本</th>
       <th>说明</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>5.3.0</td>
       <td>
        Added icon support.
       </td>
      </tr>

      <tr>
       <td>5.2.3</td>
       <td>
        Read errors generated by this function downgraded to
        <strong><code>E_NOTICE</code></strong> from <strong><code>E_WARNING</code></strong>.
       </td>
      </tr>

      <tr>
       <td>4.3.2</td>
       <td>
        Support for <abbr title="Japan Picture">JPC</abbr>, <abbr title="JPEG-2000">JP2</abbr>,
        <abbr>JPX</abbr>, <abbr title="Joint Bilevel Image Experts Group">JB2</abbr>, 
        <abbr title="X Bitmap">XBM</abbr>, and <abbr title="Wireless Bitmap">WBMP</abbr> became available.
       </td>
      </tr>

      <tr>
       <td>4.3.2</td>
       <td>
        JPEG 2000 support was added for the <code class="parameter">imageinfo</code>
        parameter.
       </td>
      </tr>

      <tr>
       <td>4.3.0</td>
       <td>
        <code class="literal">bits</code> and <code class="literal">channels</code> are present
        for other image types, too.
       </td>
      </tr>

      <tr>
       <td>4.3.0</td>
       <td>
        <code class="literal">mime</code> was added.
       </td>
      </tr>

      <tr>
       <td>4.3.0</td>
       <td>
        Support for <abbr>SWC</abbr> and <abbr title="Interchange File Format">IFF</abbr> was
        added.
       </td>
      </tr>

      <tr>
       <td>4.2.0</td>
       <td>
        Support for <abbr title="Tagged Image File Format">TIFF</abbr> was added.
       </td>
      </tr>

      <tr>
       <td>4.0.6</td>
       <td>
        Support for <abbr title="Bitmap">BMP</abbr> and <abbr title="Photoshop Document">PSD</abbr> was
        added.
       </td>
      </tr>

      <tr>
       <td>4.0.5</td>
       <td>
        URL support was added.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>

 
 <div class="refsect1 examples" id="refsect1-function.getimagesize-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-2617">
    <p><strong>示例 #6 <span class="function"><strong>getimagesize()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">list(</span><span style="color: #0000BB">$width</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$height</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$type</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$attr</span><span style="color: #007700">)&nbsp;=&nbsp;</span><span style="color: #0000BB">getimagesize</span><span style="color: #007700">(</span><span style="color: #DD0000">"img/flag.jpg"</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #DD0000">"&lt;img&nbsp;src=\"img/flag.jpg\"&nbsp;</span><span style="color: #0000BB">$attr</span><span style="color: #DD0000">&nbsp;alt=\"getimagesize()&nbsp;example\"&nbsp;/&gt;"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
   <div class="example" id="example-2618">
    <p><strong>示例 #7 getimagesize (URL)</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$size&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">getimagesize</span><span style="color: #007700">(</span><span style="color: #DD0000">"http://www.example.com/gifs/logo.gif"</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;if&nbsp;the&nbsp;file&nbsp;name&nbsp;has&nbsp;space&nbsp;in&nbsp;it,&nbsp;encode&nbsp;it&nbsp;properly<br /></span><span style="color: #0000BB">$size&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">getimagesize</span><span style="color: #007700">(</span><span style="color: #DD0000">"http://www.example.com/gifs/lo%20go.gif"</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
   <div class="example" id="example-2619">
    <p><strong>示例 #8 getimagesize() returning IPTC</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$size&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">getimagesize</span><span style="color: #007700">(</span><span style="color: #DD0000">"testimg.jpg"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$info</span><span style="color: #007700">);<br />if&nbsp;(isset(</span><span style="color: #0000BB">$info</span><span style="color: #007700">[</span><span style="color: #DD0000">"APP13"</span><span style="color: #007700">]))&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$iptc&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">iptcparse</span><span style="color: #007700">(</span><span style="color: #0000BB">$info</span><span style="color: #007700">[</span><span style="color: #DD0000">"APP13"</span><span style="color: #007700">]);<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$iptc</span><span style="color: #007700">);<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>

 
 <div class="refsect1 notes" id="refsect1-function.getimagesize-notes">
  <h3 class="title">注释</h3>
  <blockquote class="note"><p><strong class="note">注意</strong>: <p class="para">此函数不需要 GD 图象库。</p></p></blockquote>
 </div>

 
 <div class="refsect1 seealso" id="refsect1-function.getimagesize-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="function.image-type-to-mime-type.html" class="function" rel="rdfs-seeAlso">image_type_to_mime_type()</a> - 取得 getimagesize、exif_read_data、exif_thumbnail、exif_imagetype 所返回的图像类型的 MIME 类型</span></li>
    <li class="member"><span class="function"><a href="function.exif-imagetype.html" class="function" rel="rdfs-seeAlso">exif_imagetype()</a> - 判断一个图像的类型</span></li>
    <li class="member"><span class="function"><a href="function.exif-read-data.html" class="function" rel="rdfs-seeAlso">exif_read_data()</a> - 从一个图片文件中读取 EXIF 头信息</span></li>
    <li class="member"><span class="function"><a href="function.exif-thumbnail.html" class="function" rel="rdfs-seeAlso">exif_thumbnail()</a> - 检索图像的嵌入式缩略图</span></li>
   </ul>
  </p>
 </div>

 </div></div></div></body></html>